---
id: tls_server
title: TLS Server
sidebar_label: TLS Server
slug: /api/outstation/tls_server
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Creating a TLS server for outstation instances is exactly the same process as a [TCP server](./tcp_server.mdx),
except that an extra `TlsServerConfig` is required. For more details about TLS support and the configuration options,
check the [TLS general information](../tls.mdx) page.

## Examples

### Certificate chain configuration

<Tabs
groupId="language"
defaultValue="Rust"
values={[
{label: 'Rust', value: 'Rust'},
{label: 'C', value: 'C'},
{label: 'C++', value: 'C++'},
{label: 'Java', value: 'Java'},
{label: 'C#', value: 'C#'},
]}>
<TabItem value="Rust">

```rust
{{#include ../dnp3/examples/outstation.rs:tls_ca_chain_config}}

{{#include ../dnp3/examples/outstation.rs:create_tls_server}}
```

</TabItem>
<TabItem value="C">

```c
{{#include ../ffi/bindings/c/outstation_example.c:tls_ca_chain_config}}

{{#include ../ffi/bindings/c/outstation_example.c:create_tls_server}}
// check error
```

</TabItem>
<TabItem value="C++">

```cpp
{{#include ../ffi/bindings/c/outstation_example.cpp:tls_ca_chain_config}}

{{#include ../ffi/bindings/c/outstation_example.cpp:create_tls_server}}
```

</TabItem>
<TabItem value="Java">

```java
{{#include ../ffi/bindings/java/examples/src/main/java/io/stepfunc/dnp3/examples/OutstationExample.java:tls_ca_chain_config}}

{{#include ../ffi/bindings/java/examples/src/main/java/io/stepfunc/dnp3/examples/OutstationExample.java:create_tls_server}}
```

</TabItem>
<TabItem value="C#">

```csharp
{{#include ../ffi/bindings/dotnet/examples/outstation/Program.cs:tls_ca_chain_config}}

{{#include ../ffi/bindings/dotnet/examples/outstation/Program.cs:create_tls_server}}
```

</TabItem>
</Tabs>

### Self-signed certificate configuration

<Tabs
groupId="language"
defaultValue="Rust"
values={[
{label: 'Rust', value: 'Rust'},
{label: 'C', value: 'C'},
{label: 'C++', value: 'C++'},
{label: 'Java', value: 'Java'},
{label: 'C#', value: 'C#'},
]}>
<TabItem value="Rust">

```rust
{{#include ../dnp3/examples/outstation.rs:tls_self_signed_config}}

{{#include ../dnp3/examples/outstation.rs:create_tls_server}}
```

</TabItem>
<TabItem value="C">

```c
{{#include ../ffi/bindings/c/outstation_example.c:tls_self_signed_config}}

{{#include ../ffi/bindings/c/outstation_example.c:create_tls_server}}
// check error
```

</TabItem>
<TabItem value="C++">

```cpp
{{#include ../ffi/bindings/c/outstation_example.cpp:tls_self_signed_config}}

{{#include ../ffi/bindings/c/outstation_example.cpp:create_tls_server}}
```

</TabItem>
<TabItem value="Java">

```java
{{#include ../ffi/bindings/java/examples/src/main/java/io/stepfunc/dnp3/examples/OutstationExample.java:tls_self_signed_config}}

{{#include ../ffi/bindings/java/examples/src/main/java/io/stepfunc/dnp3/examples/OutstationExample.java:create_tls_server}}
```

</TabItem>
<TabItem value="C#">

```csharp
{{#include ../ffi/bindings/dotnet/examples/outstation/Program.cs:tls_self_signed_config}}

{{#include ../ffi/bindings/dotnet/examples/outstation/Program.cs:create_tls_server}}
```

</TabItem>
</Tabs>
